<?php
/**
 * Put any global functions in this file - as a general rule, global functions are discouraged,
 * but sometimes it's nice to simply be able to call a short function for things like debugging
 */

/**
 * Basically an alias to var_dump, except that it is shorter and it eventually won't do a dump
 * unless the application is in debug mode
 */
function pr($input, $return = false) {

    ob_start();
    echo "<pre>\n";
    var_dump($input);
    echo "</pre>\n";
    $output = ob_get_clean();
    if ($return) return $output;
    print $output;

}

/**
 * Does the same thing as pr() but exports dump as php code instead
 */
function prx($input, $return = false) {

    ob_start();
    echo "<pre>\n";
    var_export($input);
    echo "</pre>\n";
    $output = ob_get_clean();
    if ($return) return $output;
    print $output;

}